﻿#pragma once
#include "stdafx.h"
/*
你正在使用一堆木板建造跳水板。有两种类型的木板，其中长度较短的木板长度为shorter，长度较长的木板长度为longer。你必须正好使用k块木板。编写一个方法，生成跳水板所有可能的长度。

返回的长度需要从小到大排列。

示例：

输入：
shorter = 1
longer = 2
k = 3
输出：{ 3,4,5,6 }
提示：

0 < shorter <= longer
	0 <= k <= 100000

	来源：力扣（LeetCode）
	链接：https ://leetcode-cn.com/problems/diving-board-lcci
著作权归领扣网络所有。商业转载请联系官方授权，非商业转载请注明出处。
*/
class Solution {
public:
	vector<int> divingBoard(int shorter, int longer, int k) {
		vector<int> result;
		if (k <= 0)
			return result;
		std::set<int> result_set;
		int shorter_num{}, longer_num{};
		for (shorter_num = 0; shorter_num <= k; shorter_num++)
		{
			longer_num = k - shorter_num;
			int length = shorter * shorter_num + longer * longer_num;
			result_set.insert(length);
		}
		for (int i : result_set)
			result.push_back(i);
		return result;
	}
};

void Test()
{
	Solution solution;
	solution.divingBoard(1, 1, 0);
}